<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    IDC("icdName");
    function IDC(inputId){
        var url="${ctx}/doctor/hisDataIcd10/automaticIcd";
        autoComplete(inputId,url,function(data){
            var rows = [];
            for(var i=0; i<data.length; i++){
                rows[rows.length] = {
                    data:data[i],
                    value:data[i].id,
                    result:data[i].zhongwenMingcheng
                };
            }
            return rows;
        },function(data, i, max){
            return "代码："+data.code+"  /名称："+data.zhongwenMingcheng;
        },function(event, data,formatted){
            $("#IDCName").val(data.zhongwenMingcheng);
            $("#code").val(data.pinyinIndex);
        })
    }
/*
    function bottomMasage(){
        var obj = document.getElementById("spanDiv");
        if(obj.style.display == "none"){
            obj.style.display = "block";
        }else{
            obj.style.display = "none";
        }
    }*/
    $(function(){
        $('#zhusuIdDiv,#examineDivId').perfectScrollbar(
                {suppressScrollX: true});
        $("#saveBtn").on('click',function(){
            if ($('#inputForm1').parsley().validate()) {
                formSubmitInput("inputForm1");
                $.ajax({
                    type: "POST",
                    data:$("#inputForm1").serialize(),
                    url: "${ctx}/doctor/clinicRecord/save?patientIdVal="+$('#patientIdVal').val()+"&clinicId="+$('#clinicIdVal').val(),
                    dataType: "json",
                    success: function (data) {
                        toastr.success(data.data);
                        loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/clinicRecord/index?clinicId='+$('#clinicIdVal').val())
                    },
                    error: function (data) {
                        toastr.error('网络连接错误,请检查网络');
                    }
                });
            }
            return false;
        })
    })

    function historyRecord(patientId,clinicId){
        history = layer.open({
            type: 2,
            title:'历史病历',
            area: ['60%', '85%'],
            fixed: false, //不固定
            maxmin: true,
            btn: [ '取消'],
            content: ctx+'/doctor/clinicRecord/historyRecord?patientId='+patientId+'&clinicId='+clinicId
        });
    }

    function clinicPrint(id,clinicId,patientId,type){
        printPdf('${ctx}/doctor/clinicRecord/recordPrint?id='+id+'&clinicId='+clinicId+'&patientId='+patientId+'&type='+type, 'id=' + id);
        $("#printchoice").hide();
    }
    function printchoice(){
        $("#printchoice").show();
    }

    window.onload = getFormDiv("inputForm1");

    function addTemplate(projectType,creator,deptCode,clinicId,patientId){
        layer.open({
            type: 2,
            title:'模板插入',
            area: ['60%', '85%'],
            fixed: false, //不固定
            maxmin: true,
            content: ctx+'/doctor/outpTreatRec/indexTreat?type='+projectType+'&creator='+creator+'&deptCode='+deptCode+'&clinicId='+clinicId+'&patientId='+patientId
        });
    }
    hiddenchoice();
    function hiddenchoice(){
        $("#printchoice").hide();
    }

</script>
<div class="panel-body">
    <div style="z-index:9999;position: absolute; background-color:#EAECF6;margin:10% 0px 0px 20%;width:300px; height:150px; border:1px solid #B3B3B3;"id="printchoice">
        <label></label><br/>
        <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="3">请选择打印类别</font></label><br/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" onclick="clinicPrint('${clinicRecord.id}','${clinicRecord.clinicId}','${clinicRecord.patientId}','1')" name="choice" value="1"/>门诊病历<br/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" onclick="clinicPrint('${clinicRecord.id}','${clinicRecord.clinicId}','${clinicRecord.patientId}','2')" name="choice" value="2"/>诊断证明
        <div style="position:absolute;right:10px;bottom:10px;"><button type="button"  onclick="hiddenchoice()" class="btn btn-primary">关闭</button></div>
    </div>
    <div class="btn-rigth">
        <button type="button" id="addTemplate" onclick="addTemplate('3','${creator}','${billingDept}','${clinicRecord.clinicId}','${clinicRecord.patientId}')" class="btn btn-info">插入模板</button>
        <button type="button" id="historyRecord" onclick="historyRecord('${clinicRecord.patientId}','${clinicRecord.clinicId}')" class="btn btn-info">历史病历</button>
        <button type="button" id="saveBtn" class="btn btn-primary">保存</button>
        <button type="button" onclick="printchoice()" class="btn btn-primary">打印</button>
    </div>
    <form id="inputForm1"  data-parsley-validate="" modelAttribute="hisDiagnosis"  method="post" class="form-horizontal">
        <input type="hidden" name="id" value="${clinicRecord.id}">
    <div  id="zhusuIdDiv">
        <div class="complaint">
            <div>主诉</div>
        </div>
        <input name="zhusu" type="hidden" id="zhusuId"  value="${clinicRecord.zhusu}">
        <div class="complaint-input" contenteditable="true" submit_id="zhusuId">
            ${clinicRecord.zhusu}
        </div>
        <div>
        <jsp:include page="clinicRecordTable.jsp"></jsp:include>
            </div>
        <div class="complaint">
            <div>处理</div>
        </div>
        <input name="dispose" type="hidden"  id="dispose"  value="${clinicRecord.dispose}">
        <div class="complaint-input" contenteditable="true" submit_id="dispose">
            ${clinicRecord.dispose}
        </div>
        <div class="complaint">
            <div>建议</div>
        </div>
        <input name="suggestion" type="hidden"  id="suggestion"  value="${clinicRecord.suggestion}">
        <div class="complaint-input" contenteditable="true" submit_id="suggestion">
            ${clinicRecord.suggestion}
        </div>
        <div class="complaint">
            <div>现病史</div>
        </div>
        <input name="xianbingshi" type="hidden"  id="xianbingshiId"  value="${clinicRecord.xianbingshi}">
        <div class="complaint-input" contenteditable="true" submit_id="xianbingshiId">
            ${clinicRecord.xianbingshi}
        </div>
        <div class="complaint">
            <div>个人史</div>
        </div>
        <input name="gerenshi" type="hidden"  id="gerenshiId"  value="${clinicRecord.gerenshi}">
        <div class="complaint-input" contenteditable="true" submit_id="gerenshiId">
            ${clinicRecord.gerenshi}
        </div>
        <div class="complaint">
            <div>既往史</div>
        </div>
        <input name="jiwangshi" type="hidden"  id="jiwangshiId" value="${clinicRecord.jiwangshi}" >
        <div class="complaint-input" contenteditable="true" submit_id="jiwangshiId">
            ${clinicRecord.jiwangshi}
        </div>
        <div class="complaint">
            <div>婚育史</div>
        </div>
        <input name="hunyushi" id="hunyushiId" type="hidden"  value="${clinicRecord.hunyushi}">
        <div class="complaint-input" contenteditable="true" submit_id="hunyushiId">
            ${clinicRecord.hunyushi}
        </div>
        <div class="complaint">
            <div>家族史</div>
        </div>
        <input name="jiazushi" id="jiazushiId" type="hidden" value="${clinicRecord.jiazushi}" class="clinicInput">
        <div class="complaint-input" contenteditable="true" submit_id="jiazushiId">
            ${clinicRecord.jiazushi}
        </div>
        <div class="complaint">
            <div>过敏史</div>
        </div>
        <input name="allergyHistory" id="allergyHistory" type="hidden" value="${clinicRecord.allergyHistory}" class="clinicInput">
        <div class="complaint-input" contenteditable="true" submit_id="allergyHistory">
            ${clinicRecord.allergyHistory}
        </div>
        <div class="complaint">
            <div>药物过敏史</div>
        </div>
        <input name="drugAllergyHistory" id="drugAllergyHistory" type="hidden" value="${clinicRecord.drugAllergyHistory}" class="clinicInput">
        <div class="complaint-input" contenteditable="true" submit_id="drugAllergyHistory">
            ${clinicRecord.drugAllergyHistory}
        </div>
    </div>

    <div class="col-sm-12 complaint-examine" id="examineDivId" style="padding: 0px">
        <div class="complaint-check">
            <div>检查检验</div>
        </div>
        <div class="animal">T: <input data-parsley-twonum="1" type="text" name="tiwen" value="${clinicRecord.tiwen}" class="form-input"> °C</div>
        <div class="animal">B: <input data-parsley-twonum="1" type="text" name="maibo" value="${clinicRecord.maibo}"  class="form-input"> 次/分</div>
        <div class="animal">R: <input type="text" name="huxi" value="${clinicRecord.huxi}" class="form-input"> 次/分</div>
        <div class="animal"> BP: <input type="text" name="xueya" value="${clinicRecord.xueya}" class="form-input"> mmHg</div>
        <div class="complaint">
            <div>体格检查</div>
        </div>
        <input name="tigejiancha" type="hidden"  id="tigejianchaId" value="${clinicRecord.tigejiancha}" >
        <div class="complaint-input" contenteditable="true" submit_id="tigejianchaId">
            ${clinicRecord.tigejiancha}
        </div>
        <div class="complaint">
            <div>专科情况</div>
        </div>
        <input name="xiaojiefenxi" type="hidden"  id="xiaojiefenxiId" value="${clinicRecord.xiaojiefenxi}" >
        <div class="complaint-input" contenteditable="true" submit_id="xiaojiefenxiId">
            ${clinicRecord.xiaojiefenxi}
        </div>
        <div class="complaint">
            <div>辅助检查</div>
        </div>
        <input name="fuzhujiancha" type="hidden"  id="fuzhujianchaId" value="${clinicRecord.fuzhujiancha}" >
        <div class="complaint-input" contenteditable="true" submit_id="fuzhujianchaId">
            ${clinicRecord.fuzhujiancha}
        </div>
    </div>
    </form>
    <div class="col-md-12 " id="regResult" style="display: none">
        <section class="panel panel-primary no-b">
            <div class="list-group" id="reg">
                <div class="col-lg-12">
                    <form:form id="inputForm" data-parsley-validate=""  modelAttribute="hisDiagnosis"  method="post" class="form-horizontal">
                        <form:hidden path="inoroutFlag" value="0"/>
                        <form:hidden path="patientId"/>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">诊断类型：</label>
                            <div class="col-sm-8">
                                <form:select path="type" maxlength="64" class="form-control">
                                    <form:options items="${fns:getDictList('DIAGNOSIS')}" htmlEscape="false"
                                                  itemLabel="label" itemValue="value"/>
                                </form:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">诊断名称：</label>
                            <div class="col-sm-8">
                                <form:input path="icdName" id="icdName" data-parsley-required="true" name="diagnosis" htmlEscape="false" class="form-control"  maxlength="40" />
                                <form:hidden path="icdCode" id="code"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">诊断时间：</label>
                            <div class="col-sm-8">
                                <form:input path="createDate" value="${time}" readonly="true" htmlEscape="false" class="form-control"  maxlength="32" data-parsley-required="true"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">诊断医生：</label>
                            <div class="col-sm-8">
                                <form:input path="diagnosisDoctor" value="${userName}" htmlEscape="false" class="form-control"  maxlength="32"/>
                            </div>
                        </div>
                    </form:form>
                </div>
            </div>
        </section>
    </div>
</div>